! function(t, n) {
	"object" == typeof exports && "object" == typeof module ? module.exports = n() : "function" == typeof define && define.amd ? define([], n) : "object" == typeof exports ? exports.TaskRunner = n() : t.TaskRunner = n()
}(window, function() {
	return function(t) {
		var n = {};

		function r(e) {
			if (n[e]) return n[e].exports;
			var i = n[e] = {
				i: e,
				l: !1,
				exports: {}
			};
			return t[e].call(i.exports, i, i.exports, r), i.l = !0, i.exports
		}
		return r.m = t, r.c = n, r.d = function(t, n, e) {
			r.o(t, n) || Object.defineProperty(t, n, {
				enumerable: !0,
				get: e
			})
		}, r.r = function(t) {
			"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, {
				value: "Module"
			}), Object.defineProperty(t, "__esModule", {
				value: !0
			})
		}, r.t = function(t, n) {
			if (1 & n && (t = r(t)), 8 & n) return t;
			if (4 & n && "object" == typeof t && t && t.__esModule) return t;
			var e = Object.create(null);
			if (r.r(e), Object.defineProperty(e, "default", {
				enumerable: !0,
				value: t
			}), 2 & n && "string" != typeof t)
				for (var i in t) r.d(e, i, function(n) {
					return t[n]
				}.bind(null, i));
			return e
		}, r.n = function(t) {
			var n = t && t.__esModule ? function() {
					return t.
					default
				} : function() {
					return t
				};
			return r.d(n, "a", n), n
		}, r.o = function(t, n) {
			return Object.prototype.hasOwnProperty.call(t, n)
		}, r.p = "", r(r.s = 0)
	}([
		function(t, n, r) {
			t.exports = r(1)
		},
		function(t, n, r) {
			"use strict";
			r.r(n);
			var e = function(t) {
				return "function" == typeof t
			}, i = function(t) {
					return "number" == typeof t && !isNaN(t)
				}, o = function(t) {
					if (e(t)) return t
				};

			function s() {
				if (this.tasks.list.length) this.tasks.running < this.concurrency && (this.tasks.list.shift()(function() {
					this.tasks.completed++, this.tasks.running--, this.duration.total = Date.now() - this.duration.start, e(this.onDone) && this.onDone(this.tasks);
					s.call(this)
				}.bind(this)), this.tasks.running++);
				else if (this.tasks.completed === this.tasks.total && (this.duration.end = Date.now(), this.duration.total = this.duration.end - this.duration.start, this.__working = !1, e(this.onEnd))) {
					var t = this.tasks.completed,
						n = this.duration;
					this.onEnd({
						completed: t,
						duration: n
					})
				}
			}

			function a() {
				if (!this.__working && (this.duration.start = Date.now(), this.__working = !0, e(this.onStart))) {
					var t = this.duration;
					this.onStart({
						duration: t
					})
				}
			}

			function u() {
				if (e(this.onAdd)) {
					var t = this.tasks;
					this.onAdd({
						tasks: t
					})
				}
			}

			function c() {
				if (e(this.onRemove)) {
					var t = this.tasks;
					this.onRemove({
						tasks: t
					})
				}
			}

			function l() {
				a.call(this), s.call(this)
			}

			function f() {
				if (this.tasks.running < this.concurrency)
					for (var t = this.concurrency === 1 / 0 ? this.tasks.list.length : this.concurrency, n = this.tasks.running; n < t; n++) s.call(this)
			}
			var h = {
				already_running: "Cannot start TaskRunner instance as it is already running!",
				auto_start_true: "Cannot programmatically start TaskRunner instance as autoStart is true!",
				add_requires_function: 'The "add" operation requires a function. Check if the first argument is a function!',
				add_multiple_requires_array_of_functions: 'The "addMultiple" operation requires an array of functions. Check if the first argument is an array and whether all the items in the array are functions!',
				concurrency_not_a_number: "Concurrency should be a positive number. Defaulting to 3.",
				concurrency_should_be_positive_integer: "Concurrency should be a positive integer. Seems like you have supplied a negative value!"
			}, d = function(t) {
					return "[TaskRunner]" + this.config.name + ": " + h[t]
				};
			r.d(n, "default", function() {
				return v
			});
			var p, k, _, y = Object.assign || function(t) {
					for (var n = 1; n < arguments.length; n++) {
						var r = arguments[n];
						for (var e in r) Object.prototype.hasOwnProperty.call(r, e) && (t[e] = r[e])
					}
					return t
				};
			var v = (k = p = function t() {
				var n = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
				! function(t, n) {
					if (!(t instanceof n)) throw new TypeError("Cannot call a class as a function")
				}(this, t), _.call(this);
				var r = n.concurrency,
					e = n.onAdd,
					i = n.onStart,
					s = n.onDone,
					a = n.onEnd,
					u = function(t, n) {
						var r = {};
						for (var e in t) n.indexOf(e) >= 0 || Object.prototype.hasOwnProperty.call(t, e) && (r[e] = t[e]);
						return r
					}(n, ["concurrency", "onAdd", "onStart", "onDone", "onEnd"]);
				this.config = y({
					autoStart: !0,
					name: "Runner " + ++t.runnerCount
				}, u), this.setConcurrency(r), this.onAdd = o(e), this.onStart = o(i), this.onDone = o(s), this.onEnd = o(a), Object.seal(this)
			}, p.runnerCount = 0, _ = function() {
				var t = this;
				this.__working = !1, this.tasks = {
					list: [],
					total: 0,
					completed: 0,
					running: 0
				}, this.duration = {
					start: 0,
					end: 0,
					total: 0
				}, this.isBusy = function() {
					return t.__working
				}, this.setConcurrency = function(n) {
					n = parseInt(n, 10), i(n) || console.warn(d.call(t, "concurrency_not_a_number")), n < 0 && (n = Math.abs(n), console.warn(d.call(t, "concurrency_should_be_positive_integer"))), t.concurrency = function(t, n, r) {
						return i(t) ? 0 === t ? r : t : n
					}(n, 3, t.tasks.total), t.__working && f.call(t)
				}, this.start = function() {
					return t.__working ? (console.warn(d.call(t, "already_running")), !1) : t.config.autoStart ? (console.warn(d.call(t, "auto_start_true")), !1) : (a.call(t), f.call(t), !0)
				}, this.add = function(n) {
					var r = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
					if (e(n)) {
						var i = t.config.autoStart;
						return r ? t.tasks.list.push(n) : t.tasks.list.unshift(n), t.tasks.total++, i && l.call(t), u.call(t), !0
					}
					throw new TypeError(d("add_requires_function"))
				}, this.addFirst = function(n) {
					t.add(n, !0)
				}, this.addMultiple = function(n, r) {
					if (function(t) {
						return t.constructor === Array
					}(n) && n.every(function(t) {
						return e(t)
					})) {
						var i = t.config.autoStart;
						return t.tasks = y({}, t.tasks, {
							list: r ? [].concat(n, t.tasks.list) : [].concat(t.tasks.list, n),
							total: t.tasks.total + n.length
						}), i && l.call(t), u.call(t), !0
					}
					throw new TypeError(d.call(t, "add_multiple_requires_array_of_functions"))
				}, this.addMultipleFirst = function(n) {
					t.addMultiple(n, first)
				}, this.remove = function() {
					var n = arguments.length > 0 && void 0 !== arguments[0] && arguments[0] ? t.tasks.list.shift() : t.tasks.list.pop();
					return t.tasks.total = t.tasks.list.length + t.tasks.completed, c.call(t), n
				}, this.removeFirst = function() {
					t.remove(!0)
				}, this.removeAt = function(n) {
					var r = t.tasks.list.splice(n, 1);
					return t.tasks.total = t.tasks.list.length + t.tasks.completed, c.call(t), r
				}, this.removeAll = function() {
					return t.tasks.list = [], t.tasks.total = t.tasks.completed, c.call(t), t.tasks.list
				}
			}, k)
		}
	]).
	default
});